<?php
namespace App\Http\Requests\Trade\Demand;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Models\Trade\Demand\DemandCollectionModel;

class ItemCollectionRequest extends FormRequest
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' => 'required|integer|min:1',
            'type' => [
                'required',
                Rule::in(DemandCollectionModel::getActionTypeList())
            ]
        ];
    }

    /**
     * 获取已定义的验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'type.in' => ':attribute 必须在[' . implode(',', DemandCollectionModel::getActionTypeList()) . ']中'
        ];
    }
}
